<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Pragma" content="no-cache" />
		<s:if test="#request.sid==2">
			<title>条码管理</title>
		</s:if>
		<s:else>
			<title>封条管理</title>
		</s:else>
		<%@ include file="/user_comm.jsp"%>
		<link rel="stylesheet"
			href="http://a.tbcdn.cn/apps/sell/1.0/publish_detail_ke.css?t=20110128editor.css" />
		<link href="<%=request.getContextPath()%>/css/prop.css"
			type="text/css" rel="stylesheet" />
		<!-- script start -->
		<script>
 // --列头全选框被单击---
	function ChkAllClick(sonName, cbAllId){
	    var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	var tempState=cbAll.checked;
	 	for(i=0;i<arrSon.length;i++) {
	  	if(arrSon[i].checked!=tempState)
	        arrSon[i].click();
	 	}
	}
	
	// --子项复选框被单击---
	function ChkSonClick(sonName, cbAllId) {
	 	var arrSon = document.getElementsByName(sonName);
	 	var cbAll = document.getElementById(cbAllId);
	 	for(var i=0; i<arrSon.length; i++) {
	     	if(!arrSon[i].checked) {
	     		cbAll.checked = false;
	     		return;
	    	}
	 	}
	 	cbAll.checked = true;
	}
	
	function statusChange(status){
		checkSubmit("0");
	}
	
	function checkSubmit(opertype){
		var selIds = checkboxvalue("chkSon");
		$d("hdfOpertype").value=opertype;
		$d("hdfIds").value=selIds;
		var form=document.getElementById("formpage");
		if(opertype=="0"){
			form.action="validate_list.do";
			form.submit();
		}else{
			if(selIds==""){
				if(opertype=="1")
					alert("请选择要分配的封条！");
				else if(opertype=="2")
					alert("请选择要回收的封条！");
				else if(opertype=="3")
					alert("请选择要作废的封条！");
				return false;
			}
			//1-分配，2-回收，3-作废
			if(opertype=="1"){
				 var txt='请选择封条所属部门：<select name="selDeptid" id="selDeptid" style="width:170px">'
					+'<option value="-1">请选择</option>'
				
				 var deptOptions=$d("selOwnerId");
				 for(var i=1;i<deptOptions.options.length;i++)
			     {
			        var varItem = deptOptions.options[i];
	        			txt += '<option value="'+varItem.value+'">'+varItem.text+'</option>';
			     }
				txt += '</select>';
				$.prompt(txt,{
					submit: mycallback1,
					buttons: { 确定: true, 取消: false }
				});
			}else if(opertype=="2"){
				var txt='确定要回收选中的封条吗?';
				$.prompt(txt,{
					submit: mycallback23,
					buttons: { 确定: true, 取消: false }
				});
			}else if(opertype=="3"){
				var txt='确定要作废选中的封条吗?<br/><font color="red">作废后将无法恢复使用</font>';
				$.prompt(txt,{
					submit: mycallback23,
					buttons: { 确定: true, 取消: false }
				});
			}
		}
		return true;
	}
	
	//--------------弹出对话框-----------------
	function mycallback1(v,m,f){
		if(v==true){
			var selDeptid=$('#selDeptid').val();
			if(selDeptid == "-1"){
				alert("请选择封条所属部门");
				return false;
			}
			$d("hdfOwnerId").value=selDeptid;
			var form=$d("formpage");
			form.action="validate_exec.do";
			form.submit();
		}
	}
	
	function mycallback23(v,m,f){
		if(v==true){
			var form=$d("formpage");
			form.action="validate_exec.do";
			form.submit();
		}
	}
</script>
		<!-- script end -->
	</head>
	<body>
		<%@ include file="/user_top.jsp"%>
		<div class="realCer">
			<!--导航-->
			<!--主体部分start-->
			<div class="realMain clearfix mt10">
				<%@ include file="/user_menu.jsp"%>
				<div class="realRight ml10 Buyer">
					<div class="mybox">
						<div class="mytit">
							<s:if test="#request.sid==2">
								条码管理
							</s:if>
							<s:else>
								封条管理
							</s:else>

						</div>
						<div class="con Orbuy">
							<s:form name="formpage" action="validate_list" namespace="/">
								<%@ include file="/messages.jsp"%>
								<div class="pCenter">
									<div class="at_tab_t">
									</div>
									<div>
										<div class="search_bcontrol">
											<s:if test="#request.sid==2">
												序列号：
											</s:if>
											<s:else>
												封条号：
											</s:else>
											<input id="seqId" name="validateDto.seqId" maxlength="20"
												value="${validateDto.seqId}" size="30" type="text" />
											<button type="submit" class="J_MakePoint btn search-btn"
												onclick="return checkSubmit('0');">
												搜索
											</button>
											<a id="search_boxtoggle" href="javascript:void(0);">更多筛选条件</a>
										</div>
										<ul id="search_mcontrol">
											<li class="col1">
												<label>
													订单号：
												</label>
												&nbsp;
												<input type="text" value="${validateDto.orderId}"
													id="orderId" maxlength="15" size="30" name="orderId" />
											</li>
											<s:if test='"1"==#request.distributeType'>
												<li class="col2">
													<div>
														<label>
															所属部门：
														</label>
														<!-- 所属部门 -->
														<s:select id="selOwnerId" name="validateDto.ownerId"
															list="#request.deptList"
															value="#request.validateDto.ownerId"
															cssStyle="width:150px" headerKey="-1" headerValue="所有"></s:select>
													</div>
												</li>
											</s:if>
										</ul>
									</div>
									<style type="text/css">
#search {
	padding: 8px;
}

#search_mcontrol {
	display: none;
}

#search_mcontrol li {
	display: inline-block;
	margin-right: 15px;
	margin-top: 7px;
}

#search_mcontrol .col1 {
	width: 360px;
}

#search_mcontrol .col2 {
	width: 360px;
}

#search_mcontrol .col3 {
	width: 178px;
}
</style>
									<script type="text/javascript"> 
					                	$(function(){
					                    	$("#search_boxtoggle").click(function(){
					                        	$("#search_mcontrol").toggle();
					                            if($("#search_mcontrol").is(":hidden"))
					                            {
					                            	$(this).text('更多筛选条件');
					                            }
					                            else
					                            {
					                            	$(this).text('精简筛选条件');
					                            }
					                        });
					                    });
					                </script>
									<s:hidden id="hdfIds" name="ids" />
									<s:hidden id="hdfOpertype" name="opertype" />
									<s:hidden id="hdfOwnerId" name="ownerId" />

									<div class="pagesMag mt10 clearfix newsPag"
										style="border-top: 1px solid #dfdfdf;">
										<p class="magtab">
											<span class="magspan ml5">筛选：</span>
											<!--
                                    <select name="status" onChange="statusChange(this.value)"> 
                                        <option value="" selected>全部</option> 
                                        <option value="01" >未激活</option> 
                                        <option value="02" >已激活</option>
                                        <option value="03" >已验证</option> 
                                        <option value="04" >业务单关闭</option>
                                        <option value="05" >已冻结</option> 
                                        <option value="06" >已作废</option>
                                    </select>
                                    -->
											
											<s:if test="#request.sid==2">
												<s:select
												list="#{'':'全部','01':'未激活','02':'已激活','03':'已验证','05':'已冻结','06':'已作废'}"
												name="validateDto.status"
												value="#request.validateDto.status" id="status"
												onChange="statusChange(this.value)">
											</s:select>
											</s:if>
											<s:else>
												<s:select
												list="#{'':'全部','01':'未激活','02':'已激活','03':'已验证','04':'业务单关闭','05':'已冻结','06':'已作废'}"
												name="validateDto.status"
												value="#request.validateDto.status" id="status"
												onChange="statusChange(this.value)">
											</s:select>
											</s:else>
											
											<s:if test='"1"==#request.distributeType'>
												<a class="at_but b_2_g" href="#"
													onclick="return checkSubmit('1');"><u></u>分配</a>
												<a class="at_but b_2_g" href="#"
													onclick="return checkSubmit('2');"><u></u>回收</a>
											</s:if>
											<a class="at_but b_2_g" href="#"
												onclick="return checkSubmit('3');"><u></u>作废</a>
										</p>
									</div>

									<table class="favorRwList mt5">
										<tr>
											<th class="title" width="40">
												<input id='chkAll' name='chkAll' type='checkbox'
													onclick="ChkAllClick('chkSon','chkAll')" />
											</th>
											<th class="title">
												<s:if test="#request.sid==2">
													序列号
												</s:if>
												<s:else>
													封条号
												</s:else>
											</th>
											<th class="title">
												订单号
											</th>
											<s:if test='"1"==#request.distributeType'>
												<th class="title">
													所属部门
												</th>
											</s:if>
											<th class="title">
												状态
											</th>
										</tr>
										<s:iterator value="#request.validList" id="ca">
											<tr>
												<td align="center" width="40">
													<s:if test='"01"==#ca.status || "04"==#ca.status'>
														<input name="chkSon" type="checkbox"
															value='<s:property value="#ca.id" />'
															onclick="ChkSonClick('chkSon','chkAll')" />
													</s:if>
													<s:else>
														<input name="chkSon" type="checkbox"
															value='<s:property value="#ca.id" />' disabled="disabled" />
													</s:else>
												</td>
												<td>
													<s:property value="#ca.seqId" />
												</td>
												<td>
													<s:property value="#ca.orderId" />
												</td>
												<s:if test='"1"==#request.distributeType'>
													<td>
														<s:property value="convertDeptId(#ca.ownerId)" />
													</td>
												</s:if>
												<!-- 01：未激活、02：已激活、03：已验证、04：业务单关闭、05:已冻结 、06: 已作废 -->
												<td>
													<s:if test='"01"==#ca.status'>未激活</s:if>
													<s:elseif test='"02"==#ca.status'>已激活</s:elseif>
													<s:elseif test='"03"==#ca.status'>已验证</s:elseif>
													<s:elseif test='"04"==#ca.status'>业务单关闭</s:elseif>
													<s:elseif test='"05"==#ca.status'>已冻结</s:elseif>
													<s:elseif test='"06"==#ca.status'>已作废</s:elseif>
													<s:else>
														<s:property value="#ca.status" />
													</s:else>
												</td>
											</tr>
										</s:iterator>
										<s:if test="#request.validList.size()==0">
											<tr>
												<s:if test='"1"==#request.distributeType'>
													<td colspan="4">
														<span class='orange1 ml5'>没有满足条件的记录</span>
													</td>
												</s:if>
												<s:else>
													<td colspan="3">
														<span class='orange1 ml5'>没有满足条件的记录</span>
													</td>
												</s:else>
											</tr>
										</s:if>
									</table>
									<s:property value="#request.allowpage" escape="false" />
								</div>
							</s:form>
						</div>
					</div>
				</div>
				<!--主体部分end-->
			</div>
		</div>
		<!--底部 start-->
		<%@ include file="/user_button.jsp"%>
		<!--底部end-->
	</body>
</html>
